package prj.carmap.mobile.activity;

import java.net.URLEncoder;

import com.loopj.android.http.AsyncHttpClient;

import prj.carmap.mobile.CarmapApplication;
import prj.carmap.mobile.R;
import prj.carmap.mobile.process.LoginProcess;
import prj.carmap.mobile.process.SellerTypeProcess;
import prj.carmap.mobile.process.UpdateVersionTask;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.EditText;

/**
 * 启动屏
 * 
 */
public class FirstSplashActivity extends Activity {

	final static String TAG = "SplashActivity";

	/** 活动判断 */
	protected boolean _active = true;

	/** 停留时间 */
	protected int _splashTime = 3000;

	private SharedPreferences mPreferences;
	static AsyncHttpClient client = new AsyncHttpClient();

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.activity_first_splash);
		CarmapApplication.addActivity(this);

		// 版本更新检查
		new UpdateVersionTask(this).checkVersion();

		// 分类信息加载
		/*
		 * SellerTypeProcess typeProcess = new SellerTypeProcess();
		 * typeProcess.setContext(this); typeProcess.setFetchOnly(true);
		 * typeProcess.getSellerTypes();
		 */

		mPreferences = PreferenceManager.getDefaultSharedPreferences(this);

	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		// 如果有触摸事件，则跳过等待
		if (event.getAction() == MotionEvent.ACTION_DOWN) {
			Editor editor = mPreferences.edit();

			editor.putBoolean("isFirstIn", false);
			// 提交修改
			editor.commit();
			FirstSplashActivity.this.startActivity(new Intent(
					FirstSplashActivity.this, MainActivity.class));
		}

		return true;
	}

}
